#ifndef JSVM_EXECUTOR_FACTORY_H
#define JSVM_EXECUTOR_FACTORY_H

#include <jsireact/JSIExecutor.h>

namespace rnjsvm {
class JSVMExecutorFactory : public facebook::react::JSExecutorFactory {
public:
    explicit JSVMExecutorFactory(facebook::react::JSIExecutor::RuntimeInstaller runtimeInstaller)
        : runtimeInstaller_(runtimeInstaller), timeoutInvoker_(facebook::react::JSIExecutor::defaultTimeoutInvoker) {}

    std::unique_ptr<facebook::react::JSExecutor> createJSExecutor(
        std::shared_ptr<facebook::react::ExecutorDelegate> delegate,
        std::shared_ptr<facebook::react::MessageQueueThread> jsQueue) override;

private:
    facebook::react::JSIExecutor::RuntimeInstaller runtimeInstaller_;
    facebook::react::JSIScopedTimeoutInvoker timeoutInvoker_;
};

class JSVMExecutor : public facebook::react::JSIExecutor {
public:
    JSVMExecutor(std::shared_ptr<facebook::jsi::Runtime> runtime,
                 std::shared_ptr<facebook::react::ExecutorDelegate> delegate,
                 std::shared_ptr<facebook::react::MessageQueueThread> jsQueue,
                 const facebook::react::JSIScopedTimeoutInvoker &timeoutInvoker, RuntimeInstaller runtimeInstaller);

private:
    facebook::react::JSIScopedTimeoutInvoker timeoutInvoker_;
};

}

#endif
